Refactor contest type inference and fix JSON serialization#1546
Merged
Conversation
AtCoder は contests/archive のレーティング対象範囲表記の区切りを "~"(例: "1200 ~ ")から "-"(例: "2000 -")へ変更した。 infer_contest_type は "~" 形式の文字列完全一致に依存していたため、 "2000 -" が AGC パターンに一致せず AGC075 以降の AGC が UNRATED 判定となり、 推定対象から除外され problem-models に反映されなくなっていた (#1522)。 ABC/ARC は contest id によるフォールバックがあり除外を免れていたため、 AGC のみが problem-models から欠落していた。 - rate_change を区切り文字・空白に依存せずレーティング範囲としてパースし、 上限なしは AGC、上限値で NEW_ARC / NEW_ABC / OLD_ABC を判定するよう変更。 従来の "~" 形式と新しい "-" 形式の双方に対応する。 - 推定できなかったフィールド (slope/intercept/variance 等) を null として 出力せず省略するよう exclude_none=True を指定。フロントエンドは null を持つ モデルを invalid と判定して difficulty を非表示にしていた (#1507, #1545)。 https://claude.ai/code/session_01Hsq4dCo1x9ve8W8inoWxe2
AtCoder がレーティング対象範囲表記の区切りを "~" から "-" へ変更したため (例: " - 1999", "2000 -", "1200 - 2799")、"~" のみで split していた getRatedTarget では新形式のコンテストがすべて Unrated 扱いになり、 コンテスト名横の色ドットや「Other Rated」系コンテストの ABC-Like / ARC-Like / AGC-Like 分類が正しく行われていなかった。 両方の区切り文字を受け付けるよう変更し、テストを追加した。 https://claude.ai/code/session_01Hsq4dCo1x9ve8W8inoWxe2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR improves the robustness of contest type classification and fixes JSON serialization to better handle missing data fields.
Key Changes
Added
_parse_rated_range()function: Extracts rating range parsing logic into a dedicated function that handles both legacy ("~") and new ("-") AtCoder rating range formats. This makes the code more maintainable and resilient to format changes.Refactored
infer_contest_type(): Simplified the contest type inference logic by using the new parsing function and threshold-based classification instead of exact string matching. This approach is more flexible and easier to extend.Fixed JSON serialization: Added
exclude_none=Trueto the S3 upload to omitNonefields from the JSON output. This prevents the frontend from receiving explicitnullvalues, which it rejects for partial models (e.g., a problem with difficulty but no time model).Implementation Details
_parse_rated_range()function uses regex to parse rating ranges and returns(lower, upper)tuples, withNonerepresenting open upper bounds (e.g., "2000 -" or "All").https://claude.ai/code/session_01Hsq4dCo1x9ve8W8inoWxe2